<?php

class Course extends MY_Controller {

    var $data = null;
    var $module = null;
    var $controller = null;
    var $url = null;
    var $table = "";
    var $submodule = null;
    

    /* @ Set Constructor  */

    public function __construct() {
        parent::__construct();
        $this->data['module'] = $this->module = $this->uri->segment(1);
        $this->data['URLPATH_IMAGES'] = URLPATH_MOD . 'modules/' . $this->module . "/asset/images/";
        $this->data['URLPATH_JS'] = URLPATH_MOD . 'modules/' . $this->module . "/asset/js/";
        $this->data['URLPATH_CSS'] = URLPATH_MOD . 'modules/' . $this->module . "/asset/css/";
        $this->data['sub_module'] = $this->submodule = $this->router->class;

        // load model
        $this->load->model($this->submodule . '_model', 'model');

        $this->plugColorbox(); // เรียกใช้ colorbox 
        // user test 
        
  
        $this->data['userdata'] = array('username' => 'jnthongluk', 'em_code' => '00202929');
        $this->data['leftmenu'] = $this->leftMenu();
        $this->setCSS($this->data['URLPATH_CSS'].'default.css');
        $this->setCSS(base_url().'assets/css/grid/grid.css');
        
        //set CSS
        // set JSS
    }

    /* @ Load Default */

    public function index() {

        
        $this->load->model('igrid_model', 'igrid');
        $sql = $this->model->wf_course_me(null, 1, 1);
        $x = new Igrid_model('',20);
        $x->setDatabase("hr");
      //            $x->showCheckboxes(true);
        $x->setQuery2($sql, 'EM_CODE', "SD:DESC", '');
        $x->setColumnHeader('EM_CODE', 'ลำดับ', Igrid_model::TYPE_RUNNO);
        $x->setColumnHeader('CO_TNAME', 'ชื่อหลักสูตร', Igrid_model::TYPE_HREF,
                $this->BASE_URL . $this->submodule . "/%EM_CODE%");
        $x->setColumnHeader('CO_SDATE', 'วันที่เปิดอบรม', Igrid_model::TYPE_HREF,
                $this->BASE_URL . $this->submodule . "/%EM_CODE%");
        
        if (isset($_POST['page'])) {
            echo $x->printTable();
            
            exit;
        } else {
            $this->data['grid'] = $x->printTable();
            
        }

        $this->data['content'] = $this->load->view("index_view", $this->data,
                true);
        $this->load->view("default", $this->data);
    }
    
    
    
    public function course_list(){
         $this->load->model('igrid_model', 'igrid');
        $sql = $this->model->wf_course(null, 1, 1);
        $x = new Igrid_model('',10);
        $x->setDatabase("hr");
        $x->showCheckboxes(true);
        $x->setQuery2($sql, 'CO_RUNNO', "CO_RUNNO:ASC", '');
        $x->setColumnHeader('CO_RUNNO', 'ลำดับ', Igrid_model::TYPE_RUNNO);
        $x->setColumnHeader('CO_TNAME', 'รหัสหลักสูตร', Igrid_model::TYPE_HREF,
                $this->BASE_URL . $this->submodule . "/%CO_RUNNO%");
     
        $x->setColumnHeader('CO_CODE', 'ชื่อ', Igrid_model::TYPE_HREF,
                $this->BASE_URL . $this->submodule . "/%CO_RUNNO%");
        
//        $x->addStandardControl(Igrid_model::STDCTRL_DELETE,
//                "tblDelete('%CO_RUNNO%')");
        
        if (isset($_POST['page'])) {
            echo $x->printTable();
            
            exit;
        } else {
            $this->data['grid'] = $x->printTable();
            
        }

        $this->data['content'] = $this->load->view("index_view", $this->data,
                true);
        $this->load->view("default", $this->data);
    }


    
    
    public function leftMenu(){
        $str = "
            <ul id='box-left-menu'>
                <li>xxxxx</li>
            </ul>
            ";
        return $str;
        
    }
    

    public function add() {
        
    }

    public function update() {
        
    }

    public function delete() {
        
    }

}

?>